package JavaSE.d4;

public class Test18 {
    public static void main(String[] args) {
        Student s []=new Student[5];
        s[0]=new Student("刘海东",21,87);
        s[1]=new Student("王梦月",22,85);
        s[2]=new Student("刘海东",20,89);
        s[3]=new Student("刘海东",23,84);
        s[4]=new Student("刘海东",21,85);
        for (Student student : s) {
            if(student.getName().equals("王梦月")){
                System.out.println(student.toString());
            }
            if(student.getAge()==22&&student.getScore()==85){
                System.out.println(student);
            }
        }

    }
}

class Student{
    private String name;
    private int age;
    private int score;

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}
